---
id: 658244fdf4b0265334711664
title: Крок 22
challengeType: 20
dashedName: step-22
---

# --description--

Зрештою, поверніть результат виклику `filter()`.

# --hints--

Поверніть результат виклику `filter()` з функції `filter_expenses_by_category`.

```js
({ test: () =>
  {
    const transformedCode = code.replace(/\r/g, "");        
    const foo = __helpers.python.getDef("\n"+transformedCode, "filter_expenses_by_category");
    const {function_body} = foo;    
    assert(function_body.match(/^\s+return\s+filter\s*\(\s*lambda\s+expense\s*:\s*expense\s*\[\s*("|')category\1\s*\]\s*==\s*category\s*,\s*expenses\s*\)/m));
  }
})
```

# --seed--

## --seed-contents--

```py
def add_expense(expenses, amount, category):
    expenses.append({'amount': amount, 'category': category})

def print_expenses(expenses):
    for expense in expenses:
        print(f'Amount: {expense["amount"]}, Category: {expense["category"]}')

def total_expenses(expenses):
    return sum(map(lambda expense: expense['amount'], expenses))

--fcc-editable-region--
def filter_expenses_by_category(expenses, category):
    filter(lambda expense: expense['category'] == category, expenses)
--fcc-editable-region--

expenses = []
```
